package com.lanzuo.pana.adapter.client.handler;

import com.lanzuo.pana.adapter.client.filter.Heartbeat;
import lombok.extern.slf4j.Slf4j;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

/**
 * @author <a href="eric_zheng@lanzuo.com.cn">eric</a>
 * @date 2025/08/12 13:24
 * @description
 */
@Slf4j
public class MessageHandler extends IoHandlerAdapter {

    @Override
    public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
        Heartbeat.send(session);
    }

    @Override
    public void messageReceived(IoSession session, Object message) throws Exception {
        String str = message.toString();
        log.info("Message Received: {}", str);
        if (str.trim().contains("ReplyPing")) {
            log.info("Get ping reply.");
        }
    }

}
